/***********************************************************************************************************************
*
* Freescale Semiconductor Inc.
* (c) Copyright 2006-2009 Freescale Semiconductor, Inc.
* ALL RIGHTS RESERVED.
*
*********************************************************************************************************************//*!
*
* @file   TSS_SensorKBI.h
*
* @brief  Functions Prototypes, constants, variables and macros for the sensing of electrodes
*
* @version 1.0.13.0
* 
* @date Dec-15-2011
* 
*
***********************************************************************************************************************/

#ifndef __TSS_SENSORKBI_H__
  #define __TSS_SENSORKBI_H__

  #include "TSS_Sensor.h"
  
  /***************************** Types ***************************/

  #if TSS_HCS08_MCU || TSS_CFV1_MCU

    /* Electrode Data */
    typedef struct {
      const UINT8 kbi_cu8ModuleID;
      #if TSS_USE_NOISE_AMPLITUDE_FILTER
        const INT8 kbi_ci8AmplitudeFilterDeltaLimit;
      #endif
    } TSS_KBI_ELECTRODE_ROMDATA;    
    
    typedef struct {
      #if TSS_USE_NOISE_AMPLITUDE_FILTER
        UINT16 kbi_u16AmplitudeFilterBase;
      #else
        UINT8 u8Dummy;
      #endif
    } TSS_KBI_ELECTRODE_RAMDATA;

  #elif TSS_KINETIS_MCU || TSS_CFM_MCU

    /* Electrode Data */
    typedef struct {
      #if TSS_USE_NOISE_AMPLITUDE_FILTER
        const INT8 kbi_ci8AmplitudeFilterDeltaLimit;
      #else
        const UINT8 u8Dummy;
      #endif
    } TSS_KBI_ELECTRODE_ROMDATA;    
    
    typedef struct {
      #if TSS_USE_NOISE_AMPLITUDE_FILTER
        UINT16 kbi_u16AmplitudeFilterBase;
      #else
        UINT8 u8Dummy;
      #endif
    } TSS_KBI_ELECTRODE_RAMDATA;

  #else /* End of TSS_KINETIS_MCU || TSS_CFM_MCU */
    #error "TSS - Not supported MCU used"
  #endif  

  /************************ Function prototypes *********************/    
      
  extern UINT8 KBI_SensorInit(void);
  /*
  function:   KBI_SensorInit
  brief:      Initializes modules for the sensing of the electrodes.
  param:      Void                           
  return:     Status code                              
  */
  
  extern UINT8 KBI_SampleElectrode(UINT8 u8ElecNum, UINT8 u8Command);
  /*
  function:   KBI_SampleElectrode
  brief:      Performs a valid reading of one electrode, and returns a status code
  param:      u8ElecNum - Number of electrode to be scanned
              u8Command - Measurement command
  return:     Status code                              
  */                           

  /*********************************************************************************
  *    Determination if KBI method is used for later conditional KBI module 
  *    initialization
  *********************************************************************************/
   
  #define TSS_KBI_USED            (TSS_DETECT_EL_MODULE(0,KBI) || TSS_DETECT_EL_MODULE(1,KBI) || TSS_DETECT_EL_MODULE(2,KBI) || TSS_DETECT_EL_MODULE(3,KBI) || TSS_DETECT_EL_MODULE(4,KBI) || TSS_DETECT_EL_MODULE(5,KBI) || TSS_DETECT_EL_MODULE(6,KBI) || TSS_DETECT_EL_MODULE(7,KBI) || TSS_DETECT_EL_MODULE(8,KBI) || TSS_DETECT_EL_MODULE(9,KBI) || TSS_DETECT_EL_MODULE(10,KBI) || TSS_DETECT_EL_MODULE(11,KBI) || TSS_DETECT_EL_MODULE(12,KBI) || TSS_DETECT_EL_MODULE(13,KBI) || TSS_DETECT_EL_MODULE(14,KBI) || TSS_DETECT_EL_MODULE(15,KBI) || TSS_DETECT_EL_MODULE(16,KBI) || TSS_DETECT_EL_MODULE(17,KBI) || TSS_DETECT_EL_MODULE(18,KBI) || TSS_DETECT_EL_MODULE(19,KBI) || TSS_DETECT_EL_MODULE(20,KBI) || TSS_DETECT_EL_MODULE(21,KBI) || TSS_DETECT_EL_MODULE(22,KBI) || TSS_DETECT_EL_MODULE(23,KBI) || TSS_DETECT_EL_MODULE(24,KBI) || TSS_DETECT_EL_MODULE(25,KBI) || TSS_DETECT_EL_MODULE(26,KBI) || TSS_DETECT_EL_MODULE(27,KBI) || TSS_DETECT_EL_MODULE(28,KBI) || TSS_DETECT_EL_MODULE(29,KBI) || TSS_DETECT_EL_MODULE(30,KBI) || TSS_DETECT_EL_MODULE(31,KBI) || TSS_DETECT_EL_MODULE(32,KBI) || TSS_DETECT_EL_MODULE(33,KBI) || TSS_DETECT_EL_MODULE(34,KBI) || TSS_DETECT_EL_MODULE(35,KBI) || TSS_DETECT_EL_MODULE(36,KBI) || TSS_DETECT_EL_MODULE(37,KBI) || TSS_DETECT_EL_MODULE(38,KBI) || TSS_DETECT_EL_MODULE(39,KBI) || TSS_DETECT_EL_MODULE(40,KBI) || TSS_DETECT_EL_MODULE(41,KBI) || TSS_DETECT_EL_MODULE(42,KBI) || TSS_DETECT_EL_MODULE(43,KBI) || TSS_DETECT_EL_MODULE(44,KBI) || TSS_DETECT_EL_MODULE(45,KBI) || TSS_DETECT_EL_MODULE(46,KBI) || TSS_DETECT_EL_MODULE(47,KBI) || TSS_DETECT_EL_MODULE(48,KBI) || TSS_DETECT_EL_MODULE(49,KBI) || TSS_DETECT_EL_MODULE(50,KBI) || TSS_DETECT_EL_MODULE(51,KBI) || TSS_DETECT_EL_MODULE(52,KBI) || TSS_DETECT_EL_MODULE(53,KBI) || TSS_DETECT_EL_MODULE(54,KBI) || TSS_DETECT_EL_MODULE(55,KBI) || TSS_DETECT_EL_MODULE(56,KBI) || TSS_DETECT_EL_MODULE(57,KBI) || TSS_DETECT_EL_MODULE(58,KBI) || TSS_DETECT_EL_MODULE(59,KBI) || TSS_DETECT_EL_MODULE(60,KBI) || TSS_DETECT_EL_MODULE(61,KBI) || TSS_DETECT_EL_MODULE(62,KBI) || TSS_DETECT_EL_MODULE(63,KBI))
  #define TSS_KBI1_USED           (TSS_DETECT_EL_MODULE(0,KBI1) || TSS_DETECT_EL_MODULE(1,KBI1) || TSS_DETECT_EL_MODULE(2,KBI1) || TSS_DETECT_EL_MODULE(3,KBI1) || TSS_DETECT_EL_MODULE(4,KBI1) || TSS_DETECT_EL_MODULE(5,KBI1) || TSS_DETECT_EL_MODULE(6,KBI1) || TSS_DETECT_EL_MODULE(7,KBI1) || TSS_DETECT_EL_MODULE(8,KBI1) || TSS_DETECT_EL_MODULE(9,KBI1) || TSS_DETECT_EL_MODULE(10,KBI1) || TSS_DETECT_EL_MODULE(11,KBI1) || TSS_DETECT_EL_MODULE(12,KBI1) || TSS_DETECT_EL_MODULE(13,KBI1) || TSS_DETECT_EL_MODULE(14,KBI1) || TSS_DETECT_EL_MODULE(15,KBI1) || TSS_DETECT_EL_MODULE(16,KBI1) || TSS_DETECT_EL_MODULE(17,KBI1) || TSS_DETECT_EL_MODULE(18,KBI1) || TSS_DETECT_EL_MODULE(19,KBI1) || TSS_DETECT_EL_MODULE(20,KBI1) || TSS_DETECT_EL_MODULE(21,KBI1) || TSS_DETECT_EL_MODULE(22,KBI1) || TSS_DETECT_EL_MODULE(23,KBI1) || TSS_DETECT_EL_MODULE(24,KBI1) || TSS_DETECT_EL_MODULE(25,KBI1) || TSS_DETECT_EL_MODULE(26,KBI1) || TSS_DETECT_EL_MODULE(27,KBI1) || TSS_DETECT_EL_MODULE(28,KBI1) || TSS_DETECT_EL_MODULE(29,KBI1) || TSS_DETECT_EL_MODULE(30,KBI1) || TSS_DETECT_EL_MODULE(31,KBI1) || TSS_DETECT_EL_MODULE(32,KBI1) || TSS_DETECT_EL_MODULE(33,KBI1) || TSS_DETECT_EL_MODULE(34,KBI1) || TSS_DETECT_EL_MODULE(35,KBI1) || TSS_DETECT_EL_MODULE(36,KBI1) || TSS_DETECT_EL_MODULE(37,KBI1) || TSS_DETECT_EL_MODULE(38,KBI1) || TSS_DETECT_EL_MODULE(39,KBI1) || TSS_DETECT_EL_MODULE(40,KBI1) || TSS_DETECT_EL_MODULE(41,KBI1) || TSS_DETECT_EL_MODULE(42,KBI1) || TSS_DETECT_EL_MODULE(43,KBI1) || TSS_DETECT_EL_MODULE(44,KBI1) || TSS_DETECT_EL_MODULE(45,KBI1) || TSS_DETECT_EL_MODULE(46,KBI1) || TSS_DETECT_EL_MODULE(47,KBI1) || TSS_DETECT_EL_MODULE(48,KBI1) || TSS_DETECT_EL_MODULE(49,KBI1) || TSS_DETECT_EL_MODULE(50,KBI1) || TSS_DETECT_EL_MODULE(51,KBI1) || TSS_DETECT_EL_MODULE(52,KBI1) || TSS_DETECT_EL_MODULE(53,KBI1) || TSS_DETECT_EL_MODULE(54,KBI1) || TSS_DETECT_EL_MODULE(55,KBI1) || TSS_DETECT_EL_MODULE(56,KBI1) || TSS_DETECT_EL_MODULE(57,KBI1) || TSS_DETECT_EL_MODULE(58,KBI1) || TSS_DETECT_EL_MODULE(59,KBI1) || TSS_DETECT_EL_MODULE(60,KBI1) || TSS_DETECT_EL_MODULE(61,KBI1) || TSS_DETECT_EL_MODULE(62,KBI1) || TSS_DETECT_EL_MODULE(63,KBI1))
  #define TSS_KBI2_USED           (TSS_DETECT_EL_MODULE(0,KBI2) || TSS_DETECT_EL_MODULE(1,KBI2) || TSS_DETECT_EL_MODULE(2,KBI2) || TSS_DETECT_EL_MODULE(3,KBI2) || TSS_DETECT_EL_MODULE(4,KBI2) || TSS_DETECT_EL_MODULE(5,KBI2) || TSS_DETECT_EL_MODULE(6,KBI2) || TSS_DETECT_EL_MODULE(7,KBI2) || TSS_DETECT_EL_MODULE(8,KBI2) || TSS_DETECT_EL_MODULE(9,KBI2) || TSS_DETECT_EL_MODULE(10,KBI2) || TSS_DETECT_EL_MODULE(11,KBI2) || TSS_DETECT_EL_MODULE(12,KBI2) || TSS_DETECT_EL_MODULE(13,KBI2) || TSS_DETECT_EL_MODULE(14,KBI2) || TSS_DETECT_EL_MODULE(15,KBI2) || TSS_DETECT_EL_MODULE(16,KBI2) || TSS_DETECT_EL_MODULE(17,KBI2) || TSS_DETECT_EL_MODULE(18,KBI2) || TSS_DETECT_EL_MODULE(19,KBI2) || TSS_DETECT_EL_MODULE(20,KBI2) || TSS_DETECT_EL_MODULE(21,KBI2) || TSS_DETECT_EL_MODULE(22,KBI2) || TSS_DETECT_EL_MODULE(23,KBI2) || TSS_DETECT_EL_MODULE(24,KBI2) || TSS_DETECT_EL_MODULE(25,KBI2) || TSS_DETECT_EL_MODULE(26,KBI2) || TSS_DETECT_EL_MODULE(27,KBI2) || TSS_DETECT_EL_MODULE(28,KBI2) || TSS_DETECT_EL_MODULE(29,KBI2) || TSS_DETECT_EL_MODULE(30,KBI2) || TSS_DETECT_EL_MODULE(31,KBI2) || TSS_DETECT_EL_MODULE(32,KBI2) || TSS_DETECT_EL_MODULE(33,KBI2) || TSS_DETECT_EL_MODULE(34,KBI2) || TSS_DETECT_EL_MODULE(35,KBI2) || TSS_DETECT_EL_MODULE(36,KBI2) || TSS_DETECT_EL_MODULE(37,KBI2) || TSS_DETECT_EL_MODULE(38,KBI2) || TSS_DETECT_EL_MODULE(39,KBI2) || TSS_DETECT_EL_MODULE(40,KBI2) || TSS_DETECT_EL_MODULE(41,KBI2) || TSS_DETECT_EL_MODULE(42,KBI2) || TSS_DETECT_EL_MODULE(43,KBI2) || TSS_DETECT_EL_MODULE(44,KBI2) || TSS_DETECT_EL_MODULE(45,KBI2) || TSS_DETECT_EL_MODULE(46,KBI2) || TSS_DETECT_EL_MODULE(47,KBI2) || TSS_DETECT_EL_MODULE(48,KBI2) || TSS_DETECT_EL_MODULE(49,KBI2) || TSS_DETECT_EL_MODULE(50,KBI2) || TSS_DETECT_EL_MODULE(51,KBI2) || TSS_DETECT_EL_MODULE(52,KBI2) || TSS_DETECT_EL_MODULE(53,KBI2) || TSS_DETECT_EL_MODULE(54,KBI2) || TSS_DETECT_EL_MODULE(55,KBI2) || TSS_DETECT_EL_MODULE(56,KBI2) || TSS_DETECT_EL_MODULE(57,KBI2) || TSS_DETECT_EL_MODULE(58,KBI2) || TSS_DETECT_EL_MODULE(59,KBI2) || TSS_DETECT_EL_MODULE(60,KBI2) || TSS_DETECT_EL_MODULE(61,KBI2) || TSS_DETECT_EL_MODULE(62,KBI2) || TSS_DETECT_EL_MODULE(63,KBI2))
  #define TSS_KBI3_USED           (TSS_DETECT_EL_MODULE(0,KBI3) || TSS_DETECT_EL_MODULE(1,KBI3) || TSS_DETECT_EL_MODULE(2,KBI3) || TSS_DETECT_EL_MODULE(3,KBI3) || TSS_DETECT_EL_MODULE(4,KBI3) || TSS_DETECT_EL_MODULE(5,KBI3) || TSS_DETECT_EL_MODULE(6,KBI3) || TSS_DETECT_EL_MODULE(7,KBI3) || TSS_DETECT_EL_MODULE(8,KBI3) || TSS_DETECT_EL_MODULE(9,KBI3) || TSS_DETECT_EL_MODULE(10,KBI3) || TSS_DETECT_EL_MODULE(11,KBI3) || TSS_DETECT_EL_MODULE(12,KBI3) || TSS_DETECT_EL_MODULE(13,KBI3) || TSS_DETECT_EL_MODULE(14,KBI3) || TSS_DETECT_EL_MODULE(15,KBI3) || TSS_DETECT_EL_MODULE(16,KBI3) || TSS_DETECT_EL_MODULE(17,KBI3) || TSS_DETECT_EL_MODULE(18,KBI3) || TSS_DETECT_EL_MODULE(19,KBI3) || TSS_DETECT_EL_MODULE(20,KBI3) || TSS_DETECT_EL_MODULE(21,KBI3) || TSS_DETECT_EL_MODULE(22,KBI3) || TSS_DETECT_EL_MODULE(23,KBI3) || TSS_DETECT_EL_MODULE(24,KBI3) || TSS_DETECT_EL_MODULE(25,KBI3) || TSS_DETECT_EL_MODULE(26,KBI3) || TSS_DETECT_EL_MODULE(27,KBI3) || TSS_DETECT_EL_MODULE(28,KBI3) || TSS_DETECT_EL_MODULE(29,KBI3) || TSS_DETECT_EL_MODULE(30,KBI3) || TSS_DETECT_EL_MODULE(31,KBI3) || TSS_DETECT_EL_MODULE(32,KBI3) || TSS_DETECT_EL_MODULE(33,KBI3) || TSS_DETECT_EL_MODULE(34,KBI3) || TSS_DETECT_EL_MODULE(35,KBI3) || TSS_DETECT_EL_MODULE(36,KBI3) || TSS_DETECT_EL_MODULE(37,KBI3) || TSS_DETECT_EL_MODULE(38,KBI3) || TSS_DETECT_EL_MODULE(39,KBI3) || TSS_DETECT_EL_MODULE(40,KBI3) || TSS_DETECT_EL_MODULE(41,KBI3) || TSS_DETECT_EL_MODULE(42,KBI3) || TSS_DETECT_EL_MODULE(43,KBI3) || TSS_DETECT_EL_MODULE(44,KBI3) || TSS_DETECT_EL_MODULE(45,KBI3) || TSS_DETECT_EL_MODULE(46,KBI3) || TSS_DETECT_EL_MODULE(47,KBI3) || TSS_DETECT_EL_MODULE(48,KBI3) || TSS_DETECT_EL_MODULE(49,KBI3) || TSS_DETECT_EL_MODULE(50,KBI3) || TSS_DETECT_EL_MODULE(51,KBI3) || TSS_DETECT_EL_MODULE(52,KBI3) || TSS_DETECT_EL_MODULE(53,KBI3) || TSS_DETECT_EL_MODULE(54,KBI3) || TSS_DETECT_EL_MODULE(55,KBI3) || TSS_DETECT_EL_MODULE(56,KBI3) || TSS_DETECT_EL_MODULE(57,KBI3) || TSS_DETECT_EL_MODULE(58,KBI3) || TSS_DETECT_EL_MODULE(59,KBI3) || TSS_DETECT_EL_MODULE(60,KBI3) || TSS_DETECT_EL_MODULE(61,KBI3) || TSS_DETECT_EL_MODULE(62,KBI3) || TSS_DETECT_EL_MODULE(63,KBI3))

  #define TSS_KBI_METHOD_USED     (TSS_DETECT_EL_METHOD(0,KBI) || TSS_DETECT_EL_METHOD(1,KBI) || TSS_DETECT_EL_METHOD(2,KBI) || TSS_DETECT_EL_METHOD(3,KBI) || TSS_DETECT_EL_METHOD(4,KBI) || TSS_DETECT_EL_METHOD(5,KBI) || TSS_DETECT_EL_METHOD(6,KBI) || TSS_DETECT_EL_METHOD(7,KBI) || TSS_DETECT_EL_METHOD(8,KBI) || TSS_DETECT_EL_METHOD(9,KBI) || TSS_DETECT_EL_METHOD(10,KBI) || TSS_DETECT_EL_METHOD(11,KBI) || TSS_DETECT_EL_METHOD(12,KBI) || TSS_DETECT_EL_METHOD(13,KBI) || TSS_DETECT_EL_METHOD(14,KBI) || TSS_DETECT_EL_METHOD(15,KBI) || TSS_DETECT_EL_METHOD(16,KBI) || TSS_DETECT_EL_METHOD(17,KBI) || TSS_DETECT_EL_METHOD(18,KBI) || TSS_DETECT_EL_METHOD(19,KBI) || TSS_DETECT_EL_METHOD(20,KBI) || TSS_DETECT_EL_METHOD(21,KBI) || TSS_DETECT_EL_METHOD(22,KBI) || TSS_DETECT_EL_METHOD(23,KBI) || TSS_DETECT_EL_METHOD(24,KBI) || TSS_DETECT_EL_METHOD(25,KBI) || TSS_DETECT_EL_METHOD(26,KBI) || TSS_DETECT_EL_METHOD(27,KBI) || TSS_DETECT_EL_METHOD(28,KBI) || TSS_DETECT_EL_METHOD(29,KBI) || TSS_DETECT_EL_METHOD(30,KBI) || TSS_DETECT_EL_METHOD(31,KBI) || TSS_DETECT_EL_METHOD(32,KBI) || TSS_DETECT_EL_METHOD(33,KBI) || TSS_DETECT_EL_METHOD(34,KBI) || TSS_DETECT_EL_METHOD(35,KBI) || TSS_DETECT_EL_METHOD(36,KBI) || TSS_DETECT_EL_METHOD(37,KBI) || TSS_DETECT_EL_METHOD(38,KBI) || TSS_DETECT_EL_METHOD(39,KBI) || TSS_DETECT_EL_METHOD(40,KBI) || TSS_DETECT_EL_METHOD(41,KBI) || TSS_DETECT_EL_METHOD(42,KBI) || TSS_DETECT_EL_METHOD(43,KBI) || TSS_DETECT_EL_METHOD(44,KBI) || TSS_DETECT_EL_METHOD(45,KBI) || TSS_DETECT_EL_METHOD(46,KBI) || TSS_DETECT_EL_METHOD(47,KBI) || TSS_DETECT_EL_METHOD(48,KBI) || TSS_DETECT_EL_METHOD(49,KBI) || TSS_DETECT_EL_METHOD(50,KBI) || TSS_DETECT_EL_METHOD(51,KBI) || TSS_DETECT_EL_METHOD(52,KBI) || TSS_DETECT_EL_METHOD(53,KBI) || TSS_DETECT_EL_METHOD(54,KBI) || TSS_DETECT_EL_METHOD(55,KBI) || TSS_DETECT_EL_METHOD(56,KBI) || TSS_DETECT_EL_METHOD(57,KBI) || TSS_DETECT_EL_METHOD(58,KBI) || TSS_DETECT_EL_METHOD(59,KBI) || TSS_DETECT_EL_METHOD(60,KBI) || TSS_DETECT_EL_METHOD(61,KBI) || TSS_DETECT_EL_METHOD(62,KBI) || TSS_DETECT_EL_METHOD(63,KBI))

  /**************** ROM & RAM Data prototypes ********************/

  #if TSS_N_ELECTRODES > 0
    #if (TSS_DETECT_EL_METHOD(0,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E0_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E0_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 1
    #if (TSS_DETECT_EL_METHOD(1,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E1_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E1_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 2
    #if (TSS_DETECT_EL_METHOD(2,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E2_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E2_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 3
    #if (TSS_DETECT_EL_METHOD(3,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E3_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E3_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 4
    #if (TSS_DETECT_EL_METHOD(4,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E4_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E4_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 5
    #if (TSS_DETECT_EL_METHOD(5,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E5_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E5_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 6
    #if (TSS_DETECT_EL_METHOD(6,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E6_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E6_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 7
    #if (TSS_DETECT_EL_METHOD(7,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E7_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E7_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 8
    #if (TSS_DETECT_EL_METHOD(8,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E8_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E8_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 9
    #if (TSS_DETECT_EL_METHOD(9,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E9_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E9_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 10
    #if (TSS_DETECT_EL_METHOD(10,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E10_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E10_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 11
    #if (TSS_DETECT_EL_METHOD(11,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E11_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E11_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 12
    #if (TSS_DETECT_EL_METHOD(12,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E12_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E12_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 13
    #if (TSS_DETECT_EL_METHOD(13,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E13_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E13_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 14
    #if (TSS_DETECT_EL_METHOD(14,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E14_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E14_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 15
    #if (TSS_DETECT_EL_METHOD(15,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E15_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E15_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 16
    #if (TSS_DETECT_EL_METHOD(16,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E16_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E16_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 17
    #if (TSS_DETECT_EL_METHOD(17,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E17_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E17_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 18
    #if (TSS_DETECT_EL_METHOD(18,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E18_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E18_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 19
    #if (TSS_DETECT_EL_METHOD(19,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E19_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E19_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 20
    #if (TSS_DETECT_EL_METHOD(20,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E20_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E20_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 21
    #if (TSS_DETECT_EL_METHOD(21,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E21_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E21_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 22
    #if (TSS_DETECT_EL_METHOD(22,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E22_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E22_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 23
    #if (TSS_DETECT_EL_METHOD(23,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E23_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E23_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 24
    #if (TSS_DETECT_EL_METHOD(24,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E24_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E24_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 25
    #if (TSS_DETECT_EL_METHOD(25,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E25_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E25_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 26
    #if (TSS_DETECT_EL_METHOD(26,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E26_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E26_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 27
    #if (TSS_DETECT_EL_METHOD(27,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E27_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E27_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 28
    #if (TSS_DETECT_EL_METHOD(28,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E28_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E28_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 29
    #if (TSS_DETECT_EL_METHOD(29,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E29_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E29_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 30
    #if (TSS_DETECT_EL_METHOD(30,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E30_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E30_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 31
    #if (TSS_DETECT_EL_METHOD(31,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E31_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E31_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 32
    #if (TSS_DETECT_EL_METHOD(32,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E32_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E32_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 33
    #if (TSS_DETECT_EL_METHOD(33,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E33_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E33_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 34
    #if (TSS_DETECT_EL_METHOD(34,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E34_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E34_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 35
    #if (TSS_DETECT_EL_METHOD(35,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E35_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E35_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 36
    #if (TSS_DETECT_EL_METHOD(36,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E36_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E36_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 37
    #if (TSS_DETECT_EL_METHOD(37,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E37_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E37_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 38
    #if (TSS_DETECT_EL_METHOD(38,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E38_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E38_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 39
    #if (TSS_DETECT_EL_METHOD(39,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E39_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E39_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 40
    #if (TSS_DETECT_EL_METHOD(40,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E40_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E40_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 41
    #if (TSS_DETECT_EL_METHOD(41,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E41_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E41_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 42
    #if (TSS_DETECT_EL_METHOD(42,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E42_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E42_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 43
    #if (TSS_DETECT_EL_METHOD(43,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E43_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E43_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 44
    #if (TSS_DETECT_EL_METHOD(44,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E44_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E44_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 45
    #if (TSS_DETECT_EL_METHOD(45,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E45_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E45_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 46
    #if (TSS_DETECT_EL_METHOD(46,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E46_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E46_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 47
    #if (TSS_DETECT_EL_METHOD(47,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E47_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E47_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 48
    #if (TSS_DETECT_EL_METHOD(48,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E48_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E48_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 49
    #if (TSS_DETECT_EL_METHOD(49,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E49_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E49_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 50
    #if (TSS_DETECT_EL_METHOD(50,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E50_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E50_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 51
    #if (TSS_DETECT_EL_METHOD(51,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E51_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E51_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 52
    #if (TSS_DETECT_EL_METHOD(52,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E52_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E52_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 53
    #if (TSS_DETECT_EL_METHOD(53,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E53_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E53_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 54
    #if (TSS_DETECT_EL_METHOD(54,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E54_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E54_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 55
    #if (TSS_DETECT_EL_METHOD(55,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E55_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E55_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 56
    #if (TSS_DETECT_EL_METHOD(56,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E56_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E56_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 57
    #if (TSS_DETECT_EL_METHOD(57,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E57_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E57_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 58
    #if (TSS_DETECT_EL_METHOD(58,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E58_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E58_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 59
    #if (TSS_DETECT_EL_METHOD(59,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E59_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E59_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 60
    #if (TSS_DETECT_EL_METHOD(60,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E60_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E60_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 61
    #if (TSS_DETECT_EL_METHOD(61,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E61_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E61_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 62
    #if (TSS_DETECT_EL_METHOD(62,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E62_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E62_RAMDATA_CONTEXT;
    #endif
  #endif

  #if TSS_N_ELECTRODES > 63
    #if (TSS_DETECT_EL_METHOD(63,KBI))
      extern const TSS_KBI_ELECTRODE_ROMDATA TSS_E63_ROMDATA_CONTEXT;
      extern       TSS_KBI_ELECTRODE_RAMDATA TSS_E63_RAMDATA_CONTEXT;
    #endif
  #endif
  
  /*******************************************************
  ******        Determine what is needed             *****
  *******************************************************/

  #if TSS_DETECT_METHOD(KBI)
    /* HW Timer */  
    #ifndef TSS_HW_TIMER_USED
      #define TSS_HW_TIMER_USED      1
    #else
      #undef TSS_HW_TIMER_USED
      #define TSS_HW_TIMER_USED      1
    #endif
    /* GPIO */        
    #ifndef TSS_HW_GPIO_USED
      #define TSS_HW_GPIO_USED       1
    #else
      #undef TSS_HW_GPIO_USED
      #define TSS_HW_GPIO_USED       1
    #endif  
  #endif  
      
  /* 
  * Handler Body of the measurement method 
  */

  #if TSS_HCS08_MCU || TSS_CFV1_MCU
    #define TSS_KBI_SAMPLE_ELECTRODE_LOW(el)     TSS_SAVE_ELECTRODE_PORT(el);          /* Save the electrode port */\
                                                 TSS_ELECTRODE_DISCHARGE(el);\
                                                 TSS_HW_TIMER_START();\
                                                 TSS_KBI_PIN_ENABLE(el);\
                                                 TSS_GOTO_WAIT();\
                                                 TSS_ELECTRODE_CHARGE(el);             /* Charges the required electrode for high state */\
                                                 TSS_KBI_PIN_DISABLE(el);\
                                                 TSS_HW_TIMER_STOP();                  /* For sure if KBI doesn't appear */\
                                                 TSS_ELECTRODE_DEFAULT(el);\
                                                 u16Result = TSS_HW_TIMER_GET_CNT();
  #elif TSS_KINETIS_MCU || TSS_CFM_MCU
    #define TSS_KBI_SAMPLE_ELECTRODE_LOW(el)     ;     /* Nothing */  
  #else /* End of TSS_KINETIS_MCU || TSS_CFM_MCU */
    #error "TSS - Not supported MCU used"
  #endif  

  /*********** Sample Electrode Low Level Routine assignment ******/

  #if TSS_N_ELECTRODES > 0
    #if (TSS_DETECT_EL_METHOD(0,KBI))
      #define TSS_E0_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(0)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 1
    #if (TSS_DETECT_EL_METHOD(1,KBI))
      #define TSS_E1_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(1)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 2
    #if (TSS_DETECT_EL_METHOD(2,KBI))
      #define TSS_E2_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(2)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 3
    #if (TSS_DETECT_EL_METHOD(3,KBI))
      #define TSS_E3_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(3)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 4
    #if (TSS_DETECT_EL_METHOD(4,KBI))
      #define TSS_E4_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(4)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 5
    #if (TSS_DETECT_EL_METHOD(5,KBI))
      #define TSS_E5_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(5)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 6
    #if (TSS_DETECT_EL_METHOD(6,KBI))
      #define TSS_E6_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(6)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 7
    #if (TSS_DETECT_EL_METHOD(7,KBI))
      #define TSS_E7_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(7)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 8
    #if (TSS_DETECT_EL_METHOD(8,KBI))
      #define TSS_E8_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(8)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 9
    #if (TSS_DETECT_EL_METHOD(9,KBI))
      #define TSS_E9_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(9)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 10
    #if (TSS_DETECT_EL_METHOD(10,KBI))
      #define TSS_E10_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(10)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 11
    #if (TSS_DETECT_EL_METHOD(11,KBI))
      #define TSS_E11_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(11)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 12
    #if (TSS_DETECT_EL_METHOD(12,KBI))
      #define TSS_E12_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(12)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 13
    #if (TSS_DETECT_EL_METHOD(13,KBI))
      #define TSS_E13_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(13)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 14
    #if (TSS_DETECT_EL_METHOD(14,KBI))
      #define TSS_E14_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(14)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 15
    #if (TSS_DETECT_EL_METHOD(15,KBI))
      #define TSS_E15_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(15)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 16
    #if (TSS_DETECT_EL_METHOD(16,KBI))
      #define TSS_E16_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(16)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 17
    #if (TSS_DETECT_EL_METHOD(17,KBI))
      #define TSS_E17_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(17)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 18
    #if (TSS_DETECT_EL_METHOD(18,KBI))
      #define TSS_E18_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(18)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 19
    #if (TSS_DETECT_EL_METHOD(19,KBI))
      #define TSS_E19_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(19)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 20
    #if (TSS_DETECT_EL_METHOD(20,KBI))
      #define TSS_E20_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(20)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 21
    #if (TSS_DETECT_EL_METHOD(21,KBI))
      #define TSS_E21_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(21)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 22
    #if (TSS_DETECT_EL_METHOD(22,KBI))
      #define TSS_E22_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(22)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 23
    #if (TSS_DETECT_EL_METHOD(23,KBI))
      #define TSS_E23_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(23)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 24
    #if (TSS_DETECT_EL_METHOD(24,KBI))
      #define TSS_E24_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(24)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 25
    #if (TSS_DETECT_EL_METHOD(25,KBI))
      #define TSS_E25_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(25)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 26
    #if (TSS_DETECT_EL_METHOD(26,KBI))
      #define TSS_E26_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(26)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 27
    #if (TSS_DETECT_EL_METHOD(27,KBI))
      #define TSS_E27_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(27)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 28
    #if (TSS_DETECT_EL_METHOD(28,KBI))
      #define TSS_E28_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(28)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 29
    #if (TSS_DETECT_EL_METHOD(29,KBI))
      #define TSS_E29_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(29)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 30
    #if (TSS_DETECT_EL_METHOD(30,KBI))
      #define TSS_E30_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(30)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 31
    #if (TSS_DETECT_EL_METHOD(31,KBI))
      #define TSS_E31_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(31)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 32
    #if (TSS_DETECT_EL_METHOD(32,KBI))
      #define TSS_E32_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(32)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 33
    #if (TSS_DETECT_EL_METHOD(33,KBI))
      #define TSS_E33_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(33)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 34
    #if (TSS_DETECT_EL_METHOD(34,KBI))
      #define TSS_E34_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(34)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 35
    #if (TSS_DETECT_EL_METHOD(35,KBI))
      #define TSS_E35_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(35)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 36
    #if (TSS_DETECT_EL_METHOD(36,KBI))
      #define TSS_E36_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(36)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 37
    #if (TSS_DETECT_EL_METHOD(37,KBI))
      #define TSS_E37_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(37)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 38
    #if (TSS_DETECT_EL_METHOD(38,KBI))
      #define TSS_E38_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(38)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 39
    #if (TSS_DETECT_EL_METHOD(39,KBI))
      #define TSS_E39_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(39)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 40
    #if (TSS_DETECT_EL_METHOD(40,KBI))
      #define TSS_E40_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(40)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 41
    #if (TSS_DETECT_EL_METHOD(41,KBI))
      #define TSS_E41_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(41)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 42
    #if (TSS_DETECT_EL_METHOD(42,KBI))
      #define TSS_E42_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(42)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 43
    #if (TSS_DETECT_EL_METHOD(43,KBI))
      #define TSS_E43_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(43)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 44
    #if (TSS_DETECT_EL_METHOD(44,KBI))
      #define TSS_E44_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(44)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 45
    #if (TSS_DETECT_EL_METHOD(45,KBI))
      #define TSS_E45_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(45)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 46
    #if (TSS_DETECT_EL_METHOD(46,KBI))
      #define TSS_E46_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(46)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 47
    #if (TSS_DETECT_EL_METHOD(47,KBI))
      #define TSS_E47_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(47)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 48
    #if (TSS_DETECT_EL_METHOD(48,KBI))
      #define TSS_E48_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(48)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 49
    #if (TSS_DETECT_EL_METHOD(49,KBI))
      #define TSS_E49_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(49)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 50
    #if (TSS_DETECT_EL_METHOD(50,KBI))
      #define TSS_E50_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(50)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 51
    #if (TSS_DETECT_EL_METHOD(51,KBI))
      #define TSS_E51_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(51)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 52
    #if (TSS_DETECT_EL_METHOD(52,KBI))
      #define TSS_E52_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(52)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 53
    #if (TSS_DETECT_EL_METHOD(53,KBI))
      #define TSS_E53_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(53)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 54
    #if (TSS_DETECT_EL_METHOD(54,KBI))
      #define TSS_E54_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(54)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 55
    #if (TSS_DETECT_EL_METHOD(55,KBI))
      #define TSS_E55_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(55)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 56
    #if (TSS_DETECT_EL_METHOD(56,KBI))
      #define TSS_E56_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(56)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 57
    #if (TSS_DETECT_EL_METHOD(57,KBI))
      #define TSS_E57_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(57)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 58
    #if (TSS_DETECT_EL_METHOD(58,KBI))
      #define TSS_E58_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(58)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 59
    #if (TSS_DETECT_EL_METHOD(59,KBI))
      #define TSS_E59_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(59)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 60
    #if (TSS_DETECT_EL_METHOD(60,KBI))
      #define TSS_E60_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(60)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 61
    #if (TSS_DETECT_EL_METHOD(61,KBI))
      #define TSS_E61_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(61)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 62
    #if (TSS_DETECT_EL_METHOD(62,KBI))
      #define TSS_E62_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(62)
    #endif
  #endif
  #if TSS_N_ELECTRODES > 63
    #if (TSS_DETECT_EL_METHOD(63,KBI))
      #define TSS_E63_SAMPLE_ELECTRODE_LOW()    TSS_KBI_SAMPLE_ELECTRODE_LOW(63)
    #endif
  #endif

  /**************** Sample Electrode Routine assignment ***********/

  #if (TSS_KINETIS_MCU == 0) && (TSS_CFM_MCU == 0)
    #define KBI_SampleElectrode           UNI_SampleElectrode
  #endif 
  
  #if TSS_N_ELECTRODES > 0
    #if (TSS_DETECT_EL_METHOD(0,KBI))
      #define TSS_E0_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 1
    #if (TSS_DETECT_EL_METHOD(1,KBI))
      #define TSS_E1_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 2
    #if (TSS_DETECT_EL_METHOD(2,KBI))
      #define TSS_E2_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 3
    #if (TSS_DETECT_EL_METHOD(3,KBI))
      #define TSS_E3_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 4
    #if (TSS_DETECT_EL_METHOD(4,KBI))
      #define TSS_E4_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 5
    #if (TSS_DETECT_EL_METHOD(5,KBI))
      #define TSS_E5_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 6
    #if (TSS_DETECT_EL_METHOD(6,KBI))
      #define TSS_E6_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 7
    #if (TSS_DETECT_EL_METHOD(7,KBI))
      #define TSS_E7_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 8
    #if (TSS_DETECT_EL_METHOD(8,KBI))
      #define TSS_E8_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 9
    #if (TSS_DETECT_EL_METHOD(9,KBI))
      #define TSS_E9_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 10
    #if (TSS_DETECT_EL_METHOD(10,KBI))
      #define TSS_E10_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 11
    #if (TSS_DETECT_EL_METHOD(11,KBI))
      #define TSS_E11_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 12
    #if (TSS_DETECT_EL_METHOD(12,KBI))
      #define TSS_E12_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 13
    #if (TSS_DETECT_EL_METHOD(13,KBI))
      #define TSS_E13_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 14
    #if (TSS_DETECT_EL_METHOD(14,KBI))
      #define TSS_E14_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 15
    #if (TSS_DETECT_EL_METHOD(15,KBI))
      #define TSS_E15_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 16
    #if (TSS_DETECT_EL_METHOD(16,KBI))
      #define TSS_E16_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 17
    #if (TSS_DETECT_EL_METHOD(17,KBI))
      #define TSS_E17_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 18
    #if (TSS_DETECT_EL_METHOD(18,KBI))
      #define TSS_E18_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 19
    #if (TSS_DETECT_EL_METHOD(19,KBI))
      #define TSS_E19_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 20
    #if (TSS_DETECT_EL_METHOD(20,KBI))
      #define TSS_E20_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 21
    #if (TSS_DETECT_EL_METHOD(21,KBI))
      #define TSS_E21_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 22
    #if (TSS_DETECT_EL_METHOD(22,KBI))
      #define TSS_E22_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 23
    #if (TSS_DETECT_EL_METHOD(23,KBI))
      #define TSS_E23_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 24
    #if (TSS_DETECT_EL_METHOD(24,KBI))
      #define TSS_E24_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 25
    #if (TSS_DETECT_EL_METHOD(25,KBI))
      #define TSS_E25_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 26
    #if (TSS_DETECT_EL_METHOD(26,KBI))
      #define TSS_E26_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 27
    #if (TSS_DETECT_EL_METHOD(27,KBI))
      #define TSS_E27_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 28
    #if (TSS_DETECT_EL_METHOD(28,KBI))
      #define TSS_E28_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 29
    #if (TSS_DETECT_EL_METHOD(29,KBI))
      #define TSS_E29_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 30
    #if (TSS_DETECT_EL_METHOD(30,KBI))
      #define TSS_E30_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 31
    #if (TSS_DETECT_EL_METHOD(31,KBI))
      #define TSS_E31_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 32
    #if (TSS_DETECT_EL_METHOD(32,KBI))
      #define TSS_E32_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 33
    #if (TSS_DETECT_EL_METHOD(33,KBI))
      #define TSS_E33_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 34
    #if (TSS_DETECT_EL_METHOD(34,KBI))
      #define TSS_E34_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 35
    #if (TSS_DETECT_EL_METHOD(35,KBI))
      #define TSS_E35_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 36
    #if (TSS_DETECT_EL_METHOD(36,KBI))
      #define TSS_E36_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 37
    #if (TSS_DETECT_EL_METHOD(37,KBI))
      #define TSS_E37_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 38
    #if (TSS_DETECT_EL_METHOD(38,KBI))
      #define TSS_E38_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 39
    #if (TSS_DETECT_EL_METHOD(39,KBI))
      #define TSS_E39_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 40
    #if (TSS_DETECT_EL_METHOD(40,KBI))
      #define TSS_E40_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 41
    #if (TSS_DETECT_EL_METHOD(41,KBI))
      #define TSS_E41_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 42
    #if (TSS_DETECT_EL_METHOD(42,KBI))
      #define TSS_E42_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 43
    #if (TSS_DETECT_EL_METHOD(43,KBI))
      #define TSS_E43_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 44
    #if (TSS_DETECT_EL_METHOD(44,KBI))
      #define TSS_E44_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 45
    #if (TSS_DETECT_EL_METHOD(45,KBI))
      #define TSS_E45_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 46
    #if (TSS_DETECT_EL_METHOD(46,KBI))
      #define TSS_E46_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 47
    #if (TSS_DETECT_EL_METHOD(47,KBI))
      #define TSS_E47_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 48
    #if (TSS_DETECT_EL_METHOD(48,KBI))
      #define TSS_E48_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 49
    #if (TSS_DETECT_EL_METHOD(49,KBI))
      #define TSS_E49_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 50
    #if (TSS_DETECT_EL_METHOD(50,KBI))
      #define TSS_E50_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 51
    #if (TSS_DETECT_EL_METHOD(51,KBI))
      #define TSS_E51_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 52
    #if (TSS_DETECT_EL_METHOD(52,KBI))
      #define TSS_E52_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 53
    #if (TSS_DETECT_EL_METHOD(53,KBI))
      #define TSS_E53_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 54
    #if (TSS_DETECT_EL_METHOD(54,KBI))
      #define TSS_E54_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 55
    #if (TSS_DETECT_EL_METHOD(55,KBI))
      #define TSS_E55_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 56
    #if (TSS_DETECT_EL_METHOD(56,KBI))
      #define TSS_E56_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 57
    #if (TSS_DETECT_EL_METHOD(57,KBI))
      #define TSS_E57_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 58
    #if (TSS_DETECT_EL_METHOD(58,KBI))
      #define TSS_E58_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 59
    #if (TSS_DETECT_EL_METHOD(59,KBI))
      #define TSS_E59_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 60
    #if (TSS_DETECT_EL_METHOD(60,KBI))
      #define TSS_E60_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 61
    #if (TSS_DETECT_EL_METHOD(61,KBI))
      #define TSS_E61_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 62
    #if (TSS_DETECT_EL_METHOD(62,KBI))
      #define TSS_E62_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
  #if TSS_N_ELECTRODES > 63
    #if (TSS_DETECT_EL_METHOD(63,KBI))
      #define TSS_E63_SAMPLE_ELECTRODE()    KBI_SampleElectrode
    #endif
  #endif
      
  /************** TSS_SystemSetup.h Settings validation ***************/

  #if TSS_N_ELECTRODES > 0
    #if (TSS_DETECT_EL_METHOD(0,KBI))
      #ifndef TSS_E0_P
        #error TSS - TSS_E0_P is not defined
      #endif
      #ifndef TSS_E0_B
        #error TSS - TSS_E0_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 1
    #if (TSS_DETECT_EL_METHOD(1,KBI))
      #ifndef TSS_E1_P
        #error TSS - TSS_E1_P is not defined
      #endif
      #ifndef TSS_E1_B
        #error TSS - TSS_E1_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 2
    #if (TSS_DETECT_EL_METHOD(2,KBI))
      #ifndef TSS_E2_P
        #error TSS - TSS_E2_P is not defined
      #endif
      #ifndef TSS_E2_B
        #error TSS - TSS_E2_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 3
    #if (TSS_DETECT_EL_METHOD(3,KBI))
      #ifndef TSS_E3_P
        #error TSS - TSS_E3_P is not defined
      #endif
      #ifndef TSS_E3_B
        #error TSS - TSS_E3_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 4
    #if (TSS_DETECT_EL_METHOD(4,KBI))
      #ifndef TSS_E4_P
        #error TSS - TSS_E4_P is not defined
      #endif
      #ifndef TSS_E4_B
        #error TSS - TSS_E4_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 5
    #if (TSS_DETECT_EL_METHOD(5,KBI))
      #ifndef TSS_E5_P
        #error TSS - TSS_E5_P is not defined
      #endif
      #ifndef TSS_E5_B
        #error TSS - TSS_E5_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 6
    #if (TSS_DETECT_EL_METHOD(6,KBI))
      #ifndef TSS_E6_P
        #error TSS - TSS_E6_P is not defined
      #endif
      #ifndef TSS_E6_B
        #error TSS - TSS_E6_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 7
    #if (TSS_DETECT_EL_METHOD(7,KBI))
      #ifndef TSS_E7_P
        #error TSS - TSS_E7_P is not defined
      #endif
      #ifndef TSS_E7_B
        #error TSS - TSS_E7_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 8
    #if (TSS_DETECT_EL_METHOD(8,KBI))
      #ifndef TSS_E8_P
        #error TSS - TSS_E8_P is not defined
      #endif
      #ifndef TSS_E8_B
        #error TSS - TSS_E8_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 9
    #if (TSS_DETECT_EL_METHOD(9,KBI))
      #ifndef TSS_E9_P
        #error TSS - TSS_E9_P is not defined
      #endif
      #ifndef TSS_E9_B
        #error TSS - TSS_E9_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 10
    #if (TSS_DETECT_EL_METHOD(10,KBI))
      #ifndef TSS_E10_P
        #error TSS - TSS_E10_P is not defined
      #endif
      #ifndef TSS_E10_B
        #error TSS - TSS_E10_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 11
    #if (TSS_DETECT_EL_METHOD(11,KBI))
      #ifndef TSS_E11_P
        #error TSS - TSS_E11_P is not defined
      #endif
      #ifndef TSS_E11_B
        #error TSS - TSS_E11_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 12
    #if (TSS_DETECT_EL_METHOD(12,KBI))
      #ifndef TSS_E12_P
        #error TSS - TSS_E12_P is not defined
      #endif
      #ifndef TSS_E12_B
        #error TSS - TSS_E12_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 13
    #if (TSS_DETECT_EL_METHOD(13,KBI))
      #ifndef TSS_E13_P
        #error TSS - TSS_E13_P is not defined
      #endif
      #ifndef TSS_E13_B
        #error TSS - TSS_E13_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 14
    #if (TSS_DETECT_EL_METHOD(14,KBI))
      #ifndef TSS_E14_P
        #error TSS - TSS_E14_P is not defined
      #endif
      #ifndef TSS_E14_B
        #error TSS - TSS_E14_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 15
    #if (TSS_DETECT_EL_METHOD(15,KBI))
      #ifndef TSS_E15_P
        #error TSS - TSS_E15_P is not defined
      #endif
      #ifndef TSS_E15_B
        #error TSS - TSS_E15_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 16
    #if (TSS_DETECT_EL_METHOD(16,KBI))
      #ifndef TSS_E16_P
        #error TSS - TSS_E16_P is not defined
      #endif
      #ifndef TSS_E16_B
        #error TSS - TSS_E16_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 17
    #if (TSS_DETECT_EL_METHOD(17,KBI))
      #ifndef TSS_E17_P
        #error TSS - TSS_E17_P is not defined
      #endif
      #ifndef TSS_E17_B
        #error TSS - TSS_E17_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 18
    #if (TSS_DETECT_EL_METHOD(18,KBI))
      #ifndef TSS_E18_P
        #error TSS - TSS_E18_P is not defined
      #endif
      #ifndef TSS_E18_B
        #error TSS - TSS_E18_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 19
    #if (TSS_DETECT_EL_METHOD(19,KBI))
      #ifndef TSS_E19_P
        #error TSS - TSS_E19_P is not defined
      #endif
      #ifndef TSS_E19_B
        #error TSS - TSS_E19_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 20
    #if (TSS_DETECT_EL_METHOD(20,KBI))
      #ifndef TSS_E20_P
        #error TSS - TSS_E20_P is not defined
      #endif
      #ifndef TSS_E20_B
        #error TSS - TSS_E20_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 21
    #if (TSS_DETECT_EL_METHOD(21,KBI))
      #ifndef TSS_E21_P
        #error TSS - TSS_E21_P is not defined
      #endif
      #ifndef TSS_E21_B
        #error TSS - TSS_E21_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 22
    #if (TSS_DETECT_EL_METHOD(22,KBI))
      #ifndef TSS_E22_P
        #error TSS - TSS_E22_P is not defined
      #endif
      #ifndef TSS_E22_B
        #error TSS - TSS_E22_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 23
    #if (TSS_DETECT_EL_METHOD(23,KBI))
      #ifndef TSS_E23_P
        #error TSS - TSS_E23_P is not defined
      #endif
      #ifndef TSS_E23_B
        #error TSS - TSS_E23_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 24
    #if (TSS_DETECT_EL_METHOD(24,KBI))
      #ifndef TSS_E24_P
        #error TSS - TSS_E24_P is not defined
      #endif
      #ifndef TSS_E24_B
        #error TSS - TSS_E24_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 25
    #if (TSS_DETECT_EL_METHOD(25,KBI))
      #ifndef TSS_E25_P
        #error TSS - TSS_E25_P is not defined
      #endif
      #ifndef TSS_E25_B
        #error TSS - TSS_E25_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 26
    #if (TSS_DETECT_EL_METHOD(26,KBI))
      #ifndef TSS_E26_P
        #error TSS - TSS_E26_P is not defined
      #endif
      #ifndef TSS_E26_B
        #error TSS - TSS_E26_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 27
    #if (TSS_DETECT_EL_METHOD(27,KBI))
      #ifndef TSS_E27_P
        #error TSS - TSS_E27_P is not defined
      #endif
      #ifndef TSS_E27_B
        #error TSS - TSS_E27_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 28
    #if (TSS_DETECT_EL_METHOD(28,KBI))
      #ifndef TSS_E28_P
        #error TSS - TSS_E28_P is not defined
      #endif
      #ifndef TSS_E28_B
        #error TSS - TSS_E28_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 29
    #if (TSS_DETECT_EL_METHOD(29,KBI))
      #ifndef TSS_E29_P
        #error TSS - TSS_E29_P is not defined
      #endif
      #ifndef TSS_E29_B
        #error TSS - TSS_E29_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 30
    #if (TSS_DETECT_EL_METHOD(30,KBI))
      #ifndef TSS_E30_P
        #error TSS - TSS_E30_P is not defined
      #endif
      #ifndef TSS_E30_B
        #error TSS - TSS_E30_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 31
    #if (TSS_DETECT_EL_METHOD(31,KBI))
      #ifndef TSS_E31_P
        #error TSS - TSS_E31_P is not defined
      #endif
      #ifndef TSS_E31_B
        #error TSS - TSS_E31_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 32
    #if (TSS_DETECT_EL_METHOD(32,KBI))
      #ifndef TSS_E32_P
        #error TSS - TSS_E32_P is not defined
      #endif
      #ifndef TSS_E32_B
        #error TSS - TSS_E32_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 33
    #if (TSS_DETECT_EL_METHOD(33,KBI))
      #ifndef TSS_E33_P
        #error TSS - TSS_E33_P is not defined
      #endif
      #ifndef TSS_E33_B
        #error TSS - TSS_E33_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 34
    #if (TSS_DETECT_EL_METHOD(34,KBI))
      #ifndef TSS_E34_P
        #error TSS - TSS_E34_P is not defined
      #endif
      #ifndef TSS_E34_B
        #error TSS - TSS_E34_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 35
    #if (TSS_DETECT_EL_METHOD(35,KBI))
      #ifndef TSS_E35_P
        #error TSS - TSS_E35_P is not defined
      #endif
      #ifndef TSS_E35_B
        #error TSS - TSS_E35_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 36
    #if (TSS_DETECT_EL_METHOD(36,KBI))
      #ifndef TSS_E36_P
        #error TSS - TSS_E36_P is not defined
      #endif
      #ifndef TSS_E36_B
        #error TSS - TSS_E36_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 37
    #if (TSS_DETECT_EL_METHOD(37,KBI))
      #ifndef TSS_E37_P
        #error TSS - TSS_E37_P is not defined
      #endif
      #ifndef TSS_E37_B
        #error TSS - TSS_E37_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 38
    #if (TSS_DETECT_EL_METHOD(38,KBI))
      #ifndef TSS_E38_P
        #error TSS - TSS_E38_P is not defined
      #endif
      #ifndef TSS_E38_B
        #error TSS - TSS_E38_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 39
    #if (TSS_DETECT_EL_METHOD(39,KBI))
      #ifndef TSS_E39_P
        #error TSS - TSS_E39_P is not defined
      #endif
      #ifndef TSS_E39_B
        #error TSS - TSS_E39_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 40
    #if (TSS_DETECT_EL_METHOD(40,KBI))
      #ifndef TSS_E40_P
        #error TSS - TSS_E40_P is not defined
      #endif
      #ifndef TSS_E40_B
        #error TSS - TSS_E40_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 41
    #if (TSS_DETECT_EL_METHOD(41,KBI))
      #ifndef TSS_E41_P
        #error TSS - TSS_E41_P is not defined
      #endif
      #ifndef TSS_E41_B
        #error TSS - TSS_E41_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 42
    #if (TSS_DETECT_EL_METHOD(42,KBI))
      #ifndef TSS_E42_P
        #error TSS - TSS_E42_P is not defined
      #endif
      #ifndef TSS_E42_B
        #error TSS - TSS_E42_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 43
    #if (TSS_DETECT_EL_METHOD(43,KBI))
      #ifndef TSS_E43_P
        #error TSS - TSS_E43_P is not defined
      #endif
      #ifndef TSS_E43_B
        #error TSS - TSS_E43_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 44
    #if (TSS_DETECT_EL_METHOD(44,KBI))
      #ifndef TSS_E44_P
        #error TSS - TSS_E44_P is not defined
      #endif
      #ifndef TSS_E44_B
        #error TSS - TSS_E44_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 45
    #if (TSS_DETECT_EL_METHOD(45,KBI))
      #ifndef TSS_E45_P
        #error TSS - TSS_E45_P is not defined
      #endif
      #ifndef TSS_E45_B
        #error TSS - TSS_E45_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 46
    #if (TSS_DETECT_EL_METHOD(46,KBI))
      #ifndef TSS_E46_P
        #error TSS - TSS_E46_P is not defined
      #endif
      #ifndef TSS_E46_B
        #error TSS - TSS_E46_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 47
    #if (TSS_DETECT_EL_METHOD(47,KBI))
      #ifndef TSS_E47_P
        #error TSS - TSS_E47_P is not defined
      #endif
      #ifndef TSS_E47_B
        #error TSS - TSS_E47_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 48
    #if (TSS_DETECT_EL_METHOD(48,KBI))
      #ifndef TSS_E48_P
        #error TSS - TSS_E48_P is not defined
      #endif
      #ifndef TSS_E48_B
        #error TSS - TSS_E48_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 49
    #if (TSS_DETECT_EL_METHOD(49,KBI))
      #ifndef TSS_E49_P
        #error TSS - TSS_E49_P is not defined
      #endif
      #ifndef TSS_E49_B
        #error TSS - TSS_E49_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 50
    #if (TSS_DETECT_EL_METHOD(50,KBI))
      #ifndef TSS_E50_P
        #error TSS - TSS_E50_P is not defined
      #endif
      #ifndef TSS_E50_B
        #error TSS - TSS_E50_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 51
    #if (TSS_DETECT_EL_METHOD(51,KBI))
      #ifndef TSS_E51_P
        #error TSS - TSS_E51_P is not defined
      #endif
      #ifndef TSS_E51_B
        #error TSS - TSS_E51_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 52
    #if (TSS_DETECT_EL_METHOD(52,KBI))
      #ifndef TSS_E52_P
        #error TSS - TSS_E52_P is not defined
      #endif
      #ifndef TSS_E52_B
        #error TSS - TSS_E52_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 53
    #if (TSS_DETECT_EL_METHOD(53,KBI))
      #ifndef TSS_E53_P
        #error TSS - TSS_E53_P is not defined
      #endif
      #ifndef TSS_E53_B
        #error TSS - TSS_E53_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 54
    #if (TSS_DETECT_EL_METHOD(54,KBI))
      #ifndef TSS_E54_P
        #error TSS - TSS_E54_P is not defined
      #endif
      #ifndef TSS_E54_B
        #error TSS - TSS_E54_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 55
    #if (TSS_DETECT_EL_METHOD(55,KBI))
      #ifndef TSS_E55_P
        #error TSS - TSS_E55_P is not defined
      #endif
      #ifndef TSS_E55_B
        #error TSS - TSS_E55_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 56
    #if (TSS_DETECT_EL_METHOD(56,KBI))
      #ifndef TSS_E56_P
        #error TSS - TSS_E56_P is not defined
      #endif
      #ifndef TSS_E56_B
        #error TSS - TSS_E56_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 57
    #if (TSS_DETECT_EL_METHOD(57,KBI))
      #ifndef TSS_E57_P
        #error TSS - TSS_E57_P is not defined
      #endif
      #ifndef TSS_E57_B
        #error TSS - TSS_E57_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 58
    #if (TSS_DETECT_EL_METHOD(58,KBI))
      #ifndef TSS_E58_P
        #error TSS - TSS_E58_P is not defined
      #endif
      #ifndef TSS_E58_B
        #error TSS - TSS_E58_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 59
    #if (TSS_DETECT_EL_METHOD(59,KBI))
      #ifndef TSS_E59_P
        #error TSS - TSS_E59_P is not defined
      #endif
      #ifndef TSS_E59_B
        #error TSS - TSS_E59_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 60
    #if (TSS_DETECT_EL_METHOD(60,KBI))
      #ifndef TSS_E60_P
        #error TSS - TSS_E60_P is not defined
      #endif
      #ifndef TSS_E60_B
        #error TSS - TSS_E60_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 61
    #if (TSS_DETECT_EL_METHOD(61,KBI))
      #ifndef TSS_E61_P
        #error TSS - TSS_E61_P is not defined
      #endif
      #ifndef TSS_E61_B
        #error TSS - TSS_E61_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 62
    #if (TSS_DETECT_EL_METHOD(62,KBI))
      #ifndef TSS_E62_P
        #error TSS - TSS_E62_P is not defined
      #endif
      #ifndef TSS_E62_B
        #error TSS - TSS_E62_B is not defined
      #endif
    #endif
  #endif
  #if TSS_N_ELECTRODES > 63
    #if (TSS_DETECT_EL_METHOD(63,KBI))
      #ifndef TSS_E63_P
        #error TSS - TSS_E63_P is not defined
      #endif
      #ifndef TSS_E63_B
        #error TSS - TSS_E63_B is not defined
      #endif
    #endif
  #endif
      
  /* Warning if PE Micro will be influenced by the method */
  #if TSS_DETECT_METHOD(KBI)
     #if TSS_USE_FREEMASTER_GUI
        #if TSS_ENABLE_DIAGNOSTIC_MESSAGES
          #warning TSS - The connection with FreeMASTER GUI via PE Micro BDM Multilink may work not properly with KBI method.
        #endif
     #endif
  #endif
      
  /* Other Validation */
      
  #if TSS_DETECT_METHOD(KBI)
    #if (TSS_HCS08_MCU == 1)
      #if (TSS_GPIO_VERSION == 2)
        #error "TSS - KBI method is not supported on this MCU"
      #endif
    #endif
  #endif

  /*********************************************************************************
   *                               KBI Control Macros
   *********************************************************************************/

  #define TSS_KBI_FALLING_EDGE                0x00U         /* Falling Edge/Low Level */
  #define TSS_KBI_RISING_EDGE                 0x01U         /* Rising Edge/High Level */
  
  /* Special MCU exceptions solving */
  #ifndef KBISC_KBIE
    #ifdef KBI1SC_KBIE
      #define KBISC_KBIE                      KBI1SC_KBIE
    #else /* JR12 exception */
      #define KBISC_KBIE                      KBI1SC_KB1IE
    #endif  
  #endif
  #ifndef KBISC_KBACK  
    #ifdef KBI1SC_KBACK
      #define KBISC_KBACK                     KBI1SC_KBACK  
    #else /* JR12 exception */
      #define KBISC_KBACK                     KBI1SC_KB1ACK  
    #endif
  #endif  
  /* JR12 exception */
  #ifndef KBI2SC_KBIE
    #define KBI2SC_KBIE                       KBI2SC_KB2IE
  #endif
  #ifndef KBI2SC_KBACK
    #define KBI2SC_KBACK                      KBI2SC_KB2ACK
  #endif
  
  /* AC128 exception */
  #ifndef KBI1SC_KBIE
    #define KBI1SC_KBIE                       KBISC_KBIE
  #endif
  #ifndef KBI1SC_KBACK  
    #define KBI1SC_KBACK                      KBISC_KBACK  
  #endif  

  /* KBI PE macros */
  #ifdef KBIPE 
    #define TSS_KBI0PE                        KBIPE_KBIPE0      
    #define TSS_KBI1PE                        KBIPE_KBIPE1      
    #define TSS_KBI2PE                        KBIPE_KBIPE2      
    #define TSS_KBI3PE                        KBIPE_KBIPE3      
    #define TSS_KBI4PE                        KBIPE_KBIPE4      
    #define TSS_KBI5PE                        KBIPE_KBIPE5      
    #define TSS_KBI6PE                        KBIPE_KBIPE6      
    #define TSS_KBI7PE                        KBIPE_KBIPE7   
   
    #define TSS_KBIP0PE                       KBIPE_KBIPE0      
    #define TSS_KBIP1PE                       KBIPE_KBIPE1      
    #define TSS_KBIP2PE                       KBIPE_KBIPE2      
    #define TSS_KBIP3PE                       KBIPE_KBIPE3      
    #define TSS_KBIP4PE                       KBIPE_KBIPE4      
    #define TSS_KBIP5PE                       KBIPE_KBIPE5      
    #define TSS_KBIP6PE                       KBIPE_KBIPE6      
    #define TSS_KBIP7PE                       KBIPE_KBIPE7   
  #else
    #ifdef KBI1PE_KBIPE0
      #define TSS_KBI0PE                      KBI1PE_KBIPE0
      #define TSS_KBIP0PE                     KBI1PE_KBIPE0      
    #else
      #define TSS_KBI0PE                      KBI1PE_KBI1PE0
      #define TSS_KBIP0PE                     KBI1PE_KBI1PE0
    #endif
    #ifdef KBI1PE_KBIPE1
      #define TSS_KBI1PE                      KBI1PE_KBIPE1
      #define TSS_KBIP1PE                     KBI1PE_KBIPE1
    #else
      #define TSS_KBI1PE                      KBI1PE_KBI1PE1
      #define TSS_KBIP1PE                     KBI1PE_KBI1PE1
    #endif
    #ifdef KBI1PE_KBIPE2
      #define TSS_KBI2PE                      KBI1PE_KBIPE2
      #define TSS_KBIP2PE                     KBI1PE_KBIPE2
    #else
      #define TSS_KBI2PE                      KBI1PE_KBI1PE2
      #define TSS_KBIP2PE                     KBI1PE_KBI1PE2
    #endif
    #ifdef KBI1PE_KBIPE3
      #define TSS_KBI3PE                      KBI1PE_KBIPE3
      #define TSS_KBIP3PE                     KBI1PE_KBIPE3
    #else
      #define TSS_KBI3PE                      KBI1PE_KBI1PE3
      #define TSS_KBIP3PE                     KBI1PE_KBI1PE3
    #endif
    #ifdef KBI1PE_KBIPE4
      #define TSS_KBI4PE                      KBI1PE_KBIPE4
      #define TSS_KBIP4PE                     KBI1PE_KBIPE4
    #else
      #define TSS_KBI4PE                      KBI1PE_KBI1PE4
      #define TSS_KBIP4PE                     KBI1PE_KBI1PE4
    #endif
    #ifdef KBI1PE_KBIPE5
      #define TSS_KBI5PE                      KBI1PE_KBIPE5
      #define TSS_KBIP5PE                     KBI1PE_KBIPE5
    #else
      #define TSS_KBI5PE                      KBI1PE_KBI1PE5
      #define TSS_KBIP5PE                     KBI1PE_KBI1PE5
    #endif
    #ifdef KBI1PE_KBIPE6
      #define TSS_KBI6PE                      KBI1PE_KBIPE6
      #define TSS_KBIP6PE                     KBI1PE_KBIPE6
    #else
      #define TSS_KBI6PE                      KBI1PE_KBI1PE6
      #define TSS_KBIP6PE                     KBI1PE_KBI1PE6
    #endif
    #ifdef KBI1PE_KBIPE7
      #define TSS_KBI7PE                      KBI1PE_KBIPE7
      #define TSS_KBIP7PE                     KBI1PE_KBIPE7
    #else
      #define TSS_KBI7PE                      KBI1PE_KBI1PE7
      #define TSS_KBIP7PE                     KBI1PE_KBI1PE7
    #endif
  #endif

  #ifdef KBI1PE    
    #ifdef KBI1PE_KBIPE0
      #define TSS_KBI1P0PE                    KBI1PE_KBIPE0
    #else
      #define TSS_KBI1P0PE                    KBI1PE_KBI1PE0
    #endif
    #ifdef KBI1PE_KBIPE1
      #define TSS_KBI1P1PE                    KBI1PE_KBIPE1
    #else
      #define TSS_KBI1P1PE                    KBI1PE_KBI1PE1
    #endif
    #ifdef KBI1PE_KBIPE2
      #define TSS_KBI1P2PE                    KBI1PE_KBIPE2
    #else
      #define TSS_KBI1P2PE                    KBI1PE_KBI1PE2
    #endif
    #ifdef KBI1PE_KBIPE3
      #define TSS_KBI1P3PE                    KBI1PE_KBIPE3
    #else
      #define TSS_KBI1P3PE                    KBI1PE_KBI1PE3
    #endif
    #ifdef KBI1PE_KBIPE4
      #define TSS_KBI1P4PE                    KBI1PE_KBIPE4
    #else
      #define TSS_KBI1P4PE                    KBI1PE_KBI1PE4
    #endif
    #ifdef KBI1PE_KBIPE5
      #define TSS_KBI1P5PE                    KBI1PE_KBIPE5
    #else
      #define TSS_KBI1P5PE                    KBI1PE_KBI1PE5
    #endif
    #ifdef KBI1PE_KBIPE6
      #define TSS_KBI1P6PE                    KBI1PE_KBIPE6
    #else
      #define TSS_KBI1P6PE                    KBI1PE_KBI1PE6
    #endif
    #ifdef KBI1PE_KBIPE7
      #define TSS_KBI1P7PE                    KBI1PE_KBIPE7
    #else
      #define TSS_KBI1P7PE                    KBI1PE_KBI1PE7
    #endif
  #else 
    #define TSS_KBI1P0PE                      KBIPE_KBIPE0      
    #define TSS_KBI1P1PE                      KBIPE_KBIPE1      
    #define TSS_KBI1P2PE                      KBIPE_KBIPE2      
    #define TSS_KBI1P3PE                      KBIPE_KBIPE3      
    #define TSS_KBI1P4PE                      KBIPE_KBIPE4      
    #define TSS_KBI1P5PE                      KBIPE_KBIPE5      
    #define TSS_KBI1P6PE                      KBIPE_KBIPE6      
    #define TSS_KBI1P7PE                      KBIPE_KBIPE7   
  #endif
  
  #ifdef KBI2PE_KBIPE0
    #define TSS_KBI2P0PE                      KBI2PE_KBIPE0
  #else
    #define TSS_KBI2P0PE                      KBI2PE_KBI2PE0
  #endif
  #ifdef KBI2PE_KBIPE1
    #define TSS_KBI2P1PE                      KBI2PE_KBIPE1
  #else
    #define TSS_KBI2P1PE                      KBI2PE_KBI2PE1
  #endif
  #ifdef KBI2PE_KBIPE2
    #define TSS_KBI2P2PE                      KBI2PE_KBIPE2
  #else
    #define TSS_KBI2P2PE                      KBI2PE_KBI2PE2
  #endif
  #ifdef KBI2PE_KBIPE3
    #define TSS_KBI2P3PE                      KBI2PE_KBIPE3
  #else
    #define TSS_KBI2P3PE                      KBI2PE_KBI2PE3
  #endif
  #ifdef KBI2PE_KBIPE4
    #define TSS_KBI2P4PE                      KBI2PE_KBIPE4
  #else
    #define TSS_KBI2P4PE                      KBI2PE_KBI2PE4
  #endif
  #ifdef KBI2PE_KBIPE5
    #define TSS_KBI2P5PE                      KBI2PE_KBIPE5
  #else
    #define TSS_KBI2P5PE                      KBI2PE_KBI2PE5
  #endif
  #ifdef KBI2PE_KBIPE6
    #define TSS_KBI2P6PE                      KBI2PE_KBIPE6
  #else
    #define TSS_KBI2P6PE                      KBI2PE_KBI2PE6
  #endif
  #ifdef KBI2PE_KBIPE7
    #define TSS_KBI2P7PE                      KBI2PE_KBIPE7
  #else
    #define TSS_KBI2P7PE                      KBI2PE_KBI2PE7
  #endif

  #ifdef KBI3PE_KBIPE0
    #define TSS_KBI3P0PE                      KBI3PE_KBIPE0
  #else
    #define TSS_KBI3P0PE                      KBI3PE_KBI3PE0
  #endif
  #ifdef KBI3PE_KBIPE1
    #define TSS_KBI3P1PE                      KBI3PE_KBIPE1
  #else
    #define TSS_KBI3P1PE                      KBI3PE_KBI3PE1
  #endif
  #ifdef KBI3PE_KBIPE2
    #define TSS_KBI3P2PE                      KBI3PE_KBIPE2
  #else
    #define TSS_KBI3P2PE                      KBI3PE_KBI3PE2
  #endif
  #ifdef KBI3PE_KBIPE3
    #define TSS_KBI3P3PE                      KBI3PE_KBIPE3
  #else
    #define TSS_KBI3P3PE                      KBI3PE_KBI3PE3
  #endif
  #ifdef KBI3PE_KBIPE4
    #define TSS_KBI3P4PE                      KBI3PE_KBIPE4
  #else
    #define TSS_KBI3P4PE                      KBI3PE_KBI3PE4
  #endif
  #ifdef KBI3PE_KBIPE5
    #define TSS_KBI3P5PE                      KBI3PE_KBIPE5
  #else
    #define TSS_KBI3P5PE                      KBI3PE_KBI3PE5
  #endif
  #ifdef KBI3PE_KBIPE6
    #define TSS_KBI3P6PE                      KBI3PE_KBIPE6
  #else
    #define TSS_KBI3P6PE                      KBI3PE_KBI3PE6
  #endif
  #ifdef KBI3PE_KBIPE7
    #define TSS_KBI3P7PE                      KBI3PE_KBIPE7
  #else
    #define TSS_KBI3P7PE                      KBI3PE_KBI3PE7
  #endif
     
  /* JR12 exception */
  #define TSS_KBIP8PE                         TSS_KBI2P0PE
  #define TSS_KBIP9PE                         TSS_KBI2P1PE  
  #define TSS_KBIP10PE                        TSS_KBI2P2PE
  #define TSS_KBIP11PE                        TSS_KBI2P3PE
  #define TSS_KBIP12PE                        TSS_KBI2P4PE
  #define TSS_KBIP13PE                        TSS_KBI2P5PE
  #define TSS_KBIP14PE                        TSS_KBI2P6PE
  #define TSS_KBIP15PE                        TSS_KBI2P7PE
  
  #define TSS_KBI_TO_PE(reg)                  TSS_##reg##PE
  #define TSS_GET_KBI_PE(name)                TSS_KBI_TO_PE(name)
  #define TSS_KBI_PIN_ENABLE(el)              (TSS_GET_KBI_PE(TSS_E##el##_TYPE) = 1u)
  #define TSS_KBI_PIN_DISABLE(el)             (TSS_GET_KBI_PE(TSS_E##el##_TYPE) = 0u)  

  /* KBI EDGE macros */
  #ifdef KBIES
    #define TSS_KBI0EDG                       KBIES_KBEDG0      
    #define TSS_KBI1EDG                       KBIES_KBEDG1      
    #define TSS_KBI2EDG                       KBIES_KBEDG2      
    #define TSS_KBI3EDG                       KBIES_KBEDG3      
    #define TSS_KBI4EDG                       KBIES_KBEDG4      
    #define TSS_KBI5EDG                       KBIES_KBEDG5      
    #define TSS_KBI6EDG                       KBIES_KBEDG6      
    #define TSS_KBI7EDG                       KBIES_KBEDG7      

    #define TSS_KBIP0EDG                      KBIES_KBEDG0      
    #define TSS_KBIP1EDG                      KBIES_KBEDG1      
    #define TSS_KBIP2EDG                      KBIES_KBEDG2      
    #define TSS_KBIP3EDG                      KBIES_KBEDG3      
    #define TSS_KBIP4EDG                      KBIES_KBEDG4      
    #define TSS_KBIP5EDG                      KBIES_KBEDG5      
    #define TSS_KBIP6EDG                      KBIES_KBEDG6      
    #define TSS_KBIP7EDG                      KBIES_KBEDG7
    /* QD4 Exception */
    #ifndef KBI1ES     
      #ifdef KBIES_KBEDG0
        #define TSS_KBI1P0EDG                 KBIES_KBEDG0      
      #endif
      #ifdef KBIES_KBEDG1
        #define TSS_KBI1P1EDG                 KBIES_KBEDG1      
      #endif
      #ifdef KBIES_KBEDG2
        #define TSS_KBI1P2EDG                 KBIES_KBEDG2      
      #endif
      #ifdef KBIES_KBEDG3
        #define TSS_KBI1P3EDG                 KBIES_KBEDG3      
      #endif
      #ifdef KBIES_KBEDG4
        #define TSS_KBI1P4EDG                 KBIES_KBEDG4      
      #endif
      #ifdef KBIES_KBEDG5
        #define TSS_KBI1P5EDG                 KBIES_KBEDG5      
      #endif
      #ifdef KBIES_KBEDG6
        #define TSS_KBI1P6EDG                 KBIES_KBEDG6      
      #endif
      #ifdef KBIES_KBEDG7
        #define TSS_KBI1P7EDG                 KBIES_KBEDG7
      #endif
    #endif
  #else
    #ifdef KBISC    
      #ifdef KBISC_KBEDG0
        #define TSS_KBI0EDG                   KBISC_KBEDG0      
        #define TSS_KBIP0EDG                  KBISC_KBEDG0      
      #endif
      #ifdef KBISC_KBEDG1      
        #define TSS_KBI1EDG                   KBISC_KBEDG1      
        #define TSS_KBIP1EDG                  KBISC_KBEDG1              
      #endif
      #ifdef KBISC_KBEDG2                     
        #define TSS_KBI2EDG                   KBISC_KBEDG2      
        #define TSS_KBIP2EDG                  KBISC_KBEDG2      
      #endif
      #ifdef KBISC_KBEDG3      
        #define TSS_KBI3EDG                   KBISC_KBEDG3      
        #define TSS_KBIP3EDG                  KBISC_KBEDG3              
      #endif
      #ifdef KBISC_KBEDG4      
        #define TSS_KBI4EDG                   KBISC_KBEDG4      
        #define TSS_KBIP4EDG                  KBISC_KBEDG4              
      #endif
      #ifdef KBISC_KBEDG5      
        #define TSS_KBI5EDG                   KBISC_KBEDG5      
        #define TSS_KBIP5EDG                  KBISC_KBEDG5              
      #endif
      #ifdef KBISC_KBEDG6             
        #define TSS_KBI6EDG                   KBISC_KBEDG6      
        #define TSS_KBIP6EDG                  KBISC_KBEDG6              
      #endif
      #ifdef KBISC_KBEDG7      
        #define TSS_KBI7EDG                   KBISC_KBEDG7      
        #define TSS_KBIP7EDG                  KBISC_KBEDG7              
      #endif
    #else
      #ifdef KBI1SC_KBEDG0
        #define TSS_KBI0EDG                   KBI1SC_KBEDG0        
        #define TSS_KBIP0EDG                  KBI1SC_KBEDG0
      #elif defined(KBI1SC_KB1EDG0)
        #define TSS_KBI0EDG                   KBI1SC_KB1EDG0
        #define TSS_KBIP0EDG                  KBI1SC_KB1EDG0
      #endif
      #ifdef KBI1SC_KBEDG1
        #define TSS_KBI1EDG                   KBI1SC_KBEDG1
        #define TSS_KBIP1EDG                  KBI1SC_KBEDG1
      #elif defined(KBI1SC_KB1EDG1)
        #define TSS_KBI1EDG                   KBI1SC_KB1EDG1
        #define TSS_KBIP1EDG                  KBI1SC_KB1EDG1
      #endif
      #ifdef KBI1SC_KBEDG2
        #define TSS_KBI2EDG                   KBI1SC_KBEDG2
        #define TSS_KBIP2EDG                  KBI1SC_KBEDG2
      #elif defined(KBI1SC_KB1EDG2)
        #define TSS_KBI2EDG                   KBI1SC_KB1EDG2
        #define TSS_KBIP2EDG                  KBI1SC_KB1EDG2
      #endif
      #ifdef KBI1SC_KBEDG3
        #define TSS_KBI3EDG                   KBI1SC_KBEDG3
        #define TSS_KBIP3EDG                  KBI1SC_KBEDG3
      #elif defined(KBI1SC_KB1EDG3)
        #define TSS_KBI3EDG                   KBI1SC_KB1EDG3
        #define TSS_KBIP3EDG                  KBI1SC_KB1EDG3
      #endif
      #ifdef KBI1SC_KBEDG4
        #define TSS_KBI4EDG                   KBI1SC_KBEDG4
        #define TSS_KBIP4EDG                  KBI1SC_KBEDG4
      #elif defined(KBI1SC_KB1EDG4)
        #define TSS_KBI4EDG                   KBI1SC_KB1EDG4
        #define TSS_KBIP4EDG                  KBI1SC_KB1EDG4
      #endif
      #ifdef KBI1SC_KBEDG5
        #define TSS_KBI5EDG                   KBI1SC_KBEDG5
        #define TSS_KBIP5EDG                  KBI1SC_KBEDG5
      #elif defined(KBI1SC_KB1EDG5)
        #define TSS_KBI5EDG                   KBI1SC_KB1EDG5
        #define TSS_KBIP5EDG                  KBI1SC_KB1EDG5
      #endif
      #ifdef KBI1SC_KBEDG6
        #define TSS_KBI6EDG                   KBI1SC_KBEDG6
        #define TSS_KBIP6EDG                  KBI1SC_KBEDG6
      #elif defined(KBI1SC_KB1EDG6)
        #define TSS_KBI6EDG                   KBI1SC_KB1EDG6
        #define TSS_KBIP6EDG                  KBI1SC_KB1EDG6
      #endif
      #ifdef KBI1SC_KBEDG7
        #define TSS_KBI7EDG                   KBI1SC_KBEDG7
        #define TSS_KBIP7EDG                  KBI1SC_KBEDG7
      #elif defined(KBI1SC_KB1EDG7)
        #define TSS_KBI7EDG                   KBI1SC_KB1EDG7
        #define TSS_KBIP7EDG                  KBI1SC_KB1EDG7
      #endif
    #endif 
  #endif   
  #ifdef KBI1ES  
    #ifdef KBI1ES_KBEDG0
      #define TSS_KBI1P0EDG                   KBI1ES_KBEDG0      
    #elif defined(KBI1ES_KB1EDG0)
      #define TSS_KBI1P0EDG                   KBI1ES_KB1EDG0      
    #endif
    #ifdef KBI1ES_KBEDG1
      #define TSS_KBI1P1EDG                   KBI1ES_KBEDG1      
    #elif defined(KBI1ES_KB1EDG1)
      #define TSS_KBI1P1EDG                   KBI1ES_KB1EDG1      
    #endif
    #ifdef KBI1ES_KBEDG2
      #define TSS_KBI1P2EDG                   KBI1ES_KBEDG2      
    #elif defined(KBI1ES_KB1EDG2)
      #define TSS_KBI1P2EDG                   KBI1ES_KB1EDG2      
    #endif
    #ifdef KBI1ES_KBEDG3
      #define TSS_KBI1P3EDG                   KBI1ES_KBEDG3      
    #elif defined(KBI1ES_KB1EDG3)
      #define TSS_KBI1P3EDG                   KBI1ES_KB1EDG3      
    #endif
    #ifdef KBI1ES_KBEDG4
      #define TSS_KBI1P4EDG                   KBI1ES_KBEDG4      
    #elif defined(KBI1ES_KB1EDG4)
      #define TSS_KBI1P4EDG                   KBI1ES_KB1EDG4      
    #endif
    #ifdef KBI1ES_KBEDG5
      #define TSS_KBI1P5EDG                   KBI1ES_KBEDG5      
    #elif defined(KBI1ES_KB1EDG5)
      #define TSS_KBI1P5EDG                   KBI1ES_KB1EDG5      
    #endif
    #ifdef KBI1ES_KBEDG6
      #define TSS_KBI1P6EDG                   KBI1ES_KBEDG6      
    #elif defined(KBI1ES_KB1EDG6)
      #define TSS_KBI1P6EDG                   KBI1ES_KB1EDG6      
    #endif
    #ifdef KBI1ES_KBEDG7
      #define TSS_KBI1P7EDG                   KBI1ES_KBEDG7
    #elif defined(KBI1ES_KB1EDG7)
      #define TSS_KBI1P7EDG                   KBI1ES_KB1EDG7      
    #endif
    /* CFV1 JM128 Exception */
    #ifndef KBIES     
      #ifdef KBI1ES_KBEDG0
        #define TSS_KBI0EDG                   KBI1ES_KBEDG0      
        #define TSS_KBIP0EDG                  KBI1ES_KBEDG0      
      #endif
      #ifdef KBI1ES_KBEDG1
        #define TSS_KBI1EDG                   KBI1ES_KBEDG1      
        #define TSS_KBIP1EDG                  KBI1ES_KBEDG1      
      #endif
      #ifdef KBI1ES_KBEDG2
        #define TSS_KBI2EDG                   KBI1ES_KBEDG2      
        #define TSS_KBIP2EDG                  KBI1ES_KBEDG2      
      #endif
      #ifdef KBI1ES_KBEDG3
        #define TSS_KBI3EDG                   KBI1ES_KBEDG3      
        #define TSS_KBIP3EDG                  KBI1ES_KBEDG3      
      #endif
      #ifdef KBI1ES_KBEDG4
        #define TSS_KBI4EDG                   KBI1ES_KBEDG4      
        #define TSS_KBIP4EDG                  KBI1ES_KBEDG4      
      #endif
      #ifdef KBI1ES_KBEDG5
        #define TSS_KBI5EDG                   KBI1ES_KBEDG5              
        #define TSS_KBIP5EDG                  KBI1ES_KBEDG5      
      #endif
      #ifdef KBI1ES_KBEDG6
        #define TSS_KBI6EDG                   KBI1ES_KBEDG6      
        #define TSS_KBIP6EDG                  KBI1ES_KBEDG6      
      #endif
      #ifdef KBI1ES_KBEDG7
        #define TSS_KBI7EDG                   KBI1ES_KBEDG7
        #define TSS_KBIP7EDG                  KBI1ES_KBEDG7
      #endif
    #endif
  #else
    #ifdef KBI1SC    
      #ifdef KBI1SC_KBEDG0
        #define TSS_KBI1P0EDG                 KBI1SC_KBEDG0
      #elif defined(KBI1SC_KB1EDG0)
        #define TSS_KBI1P0EDG                 KBI1SC_KB1EDG0
      #endif
      #ifdef KBI1SC_KBEDG1
        #define TSS_KBI1P1EDG                 KBI1SC_KBEDG1
      #elif defined(KBI1SC_KB1EDG1)
        #define TSS_KBI1P1EDG                 KBI1SC_KB1EDG1
      #endif
      #ifdef KBI1SC_KBEDG2
        #define TSS_KBI1P2EDG                 KBI1SC_KBEDG2
      #elif defined(KBI1SC_KB1EDG2)
        #define TSS_KBI1P2EDG                 KBI1SC_KB1EDG2
      #endif
      #ifdef KBI1SC_KBEDG3
        #define TSS_KBI1P3EDG                 KBI1SC_KBEDG3
      #elif defined(KBI1SC_KB1EDG3)
        #define TSS_KBI1P3EDG                 KBI1SC_KB1EDG3
      #endif
      #ifdef KBI1SC_KBEDG4
        #define TSS_KBI1P4EDG                 KBI1SC_KBEDG4
      #elif defined(KBI1SC_KB1EDG4)
        #define TSS_KBI1P4EDG                 KBI1SC_KB1EDG4
      #endif
      #ifdef KBI1SC_KBEDG5
        #define TSS_KBI1P5EDG                 KBI1SC_KBEDG5
      #elif defined(KBI1SC_KB1EDG5)
        #define TSS_KBI1P5EDG                 KBI1SC_KB1EDG5
      #endif
      #ifdef KBI1SC_KBEDG6
        #define TSS_KBI1P6EDG                 KBI1SC_KBEDG6
      #elif defined(KBI1SC_KB1EDG6)
        #define TSS_KBI1P6EDG                 KBI1SC_KB1EDG6
      #endif
      #ifdef KBI1SC_KBEDG7
        #define TSS_KBI1P7EDG                 KBI1SC_KBEDG7
      #elif defined(KBI1SC_KB1EDG7)
        #define TSS_KBI1P7EDG                 KBI1SC_KB1EDG7
      #endif      
    #else
      #ifdef KBISC_KBEDG0
        #define TSS_KBI1P0EDG                 KBISC_KBEDG0      
      #endif
      #ifdef KBISC_KBEDG1      
        #define TSS_KBI1P1EDG                 KBISC_KBEDG1      
      #endif
      #ifdef KBISC_KBEDG2      
        #define TSS_KBI1P2EDG                 KBISC_KBEDG2      
      #endif
      #ifdef KBISC_KBEDG3      
        #define TSS_KBI1P3EDG                 KBISC_KBEDG3      
      #endif
      #ifdef KBISC_KBEDG4      
        #define TSS_KBI1P4EDG                 KBISC_KBEDG4      
      #endif
      #ifdef KBISC_KBEDG5      
        #define TSS_KBI1P5EDG                 KBISC_KBEDG5      
      #endif
      #ifdef KBISC_KBEDG6      
        #define TSS_KBI1P6EDG                 KBISC_KBEDG6      
      #endif
      #ifdef KBISC_KBEDG7      
        #define TSS_KBI1P7EDG                 KBISC_KBEDG7    
      #endif
    #endif
  #endif
  #ifdef KBI2ES
    #ifdef KBI2ES_KBEDG0
      #define TSS_KBI2P0EDG                   KBI2ES_KBEDG0      
    #elif defined(KBI2ES_KB2EDG0)   
      #define TSS_KBI2P0EDG                   KBI2ES_KB2EDG0      
    #endif
    #ifdef KBI2ES_KBEDG1
      #define TSS_KBI2P1EDG                   KBI2ES_KBEDG1      
    #elif defined(KBI2ES_KB2EDG1)   
      #define TSS_KBI2P1EDG                   KBI2ES_KB2EDG1      
    #endif
    #ifdef KBI2ES_KBEDG2
      #define TSS_KBI2P2EDG                   KBI2ES_KBEDG2      
    #elif defined(KBI2ES_KB2EDG2)   
      #define TSS_KBI2P2EDG                   KBI2ES_KB2EDG2      
    #endif
    #ifdef KBI2ES_KBEDG3
      #define TSS_KBI2P3EDG                   KBI2ES_KBEDG3      
    #elif defined(KBI2ES_KB2EDG3)   
      #define TSS_KBI2P3EDG                   KBI2ES_KB2EDG3      
    #endif
    #ifdef KBI2ES_KBEDG4
      #define TSS_KBI2P4EDG                   KBI2ES_KBEDG4      
    #elif defined(KBI2ES_KB2EDG4)   
      #define TSS_KBI2P4EDG                   KBI2ES_KB2EDG4      
    #endif
    #ifdef KBI2ES_KBEDG5
      #define TSS_KBI2P5EDG                   KBI2ES_KBEDG5      
    #elif defined(KBI2ES_KB2EDG5)   
      #define TSS_KBI2P5EDG                   KBI2ES_KB2EDG5      
    #endif
    #ifdef KBI2ES_KBEDG6
      #define TSS_KBI2P6EDG                   KBI2ES_KBEDG6      
    #elif defined(KBI2ES_KB2EDG6)   
      #define TSS_KBI2P6EDG                   KBI2ES_KB2EDG6      
    #endif
    #ifdef KBI2ES_KBEDG7
      #define TSS_KBI2P7EDG                   KBI2ES_KBEDG7      
    #elif defined(KBI2ES_KB2EDG7)   
      #define TSS_KBI2P7EDG                   KBI2ES_KB2EDG7      
    #endif
  #else
    #ifdef KBI2SC_KBEDG0
      #define TSS_KBI2P0EDG                   KBI2SC_KBEDG0
    #elif defined(KBI2SC_KB2EDG0)
      #define TSS_KBI2P0EDG                   KBI2SC_KB2EDG0
    #endif
    #ifdef KBI2SC_KBEDG1
      #define TSS_KBI2P1EDG                   KBI2SC_KBEDG1
    #elif defined(KBI2SC_KB2EDG1)
      #define TSS_KBI2P1EDG                   KBI2SC_KB2EDG1
    #endif
    #ifdef KBI2SC_KBEDG2
      #define TSS_KBI2P2EDG                   KBI2SC_KBEDG2
    #elif defined(KBI2SC_KB2EDG2)
      #define TSS_KBI2P2EDG                   KBI2SC_KB2EDG2
    #endif
    #ifdef KBI2SC_KBEDG3
      #define TSS_KBI2P3EDG                   KBI2SC_KBEDG3
    #elif defined(KBI2SC_KB2EDG3)
      #define TSS_KBI2P3EDG                   KBI2SC_KB2EDG3
    #endif
    #ifdef KBI2SC_KBEDG4
      #define TSS_KBI2P4EDG                   KBI2SC_KBEDG4
    #elif defined(KBI2SC_KB2EDG4)
      #define TSS_KBI2P4EDG                   KBI2SC_KB2EDG4
    #endif
    #ifdef KBI2SC_KBEDG5
      #define TSS_KBI2P5EDG                   KBI2SC_KBEDG5
    #elif defined(KBI2SC_KB2EDG5)
      #define TSS_KBI2P5EDG                   KBI2SC_KB2EDG5
    #endif
    #ifdef KBI2SC_KBEDG6
      #define TSS_KBI2P6EDG                   KBI2SC_KBEDG6
    #elif defined(KBI2SC_KB2EDG6)
      #define TSS_KBI2P6EDG                   KBI2SC_KB2EDG6
    #endif
    #ifdef KBI2SC_KBEDG7
      #define TSS_KBI2P7EDG                   KBI2SC_KBEDG7
    #elif defined(KBI2SC_KB2EDG7)
      #define TSS_KBI2P7EDG                   KBI2SC_KB2EDG7
    #endif  
  #endif
  #ifdef KBI3ES
    #ifdef KBI3ES_KBEDG0 
      #define TSS_KBI3P0EDG                   KBI3ES_KBEDG0      
    #elif defined(KBI3ES_KB3EDG0)
      #define TSS_KBI3P0EDG                   KBI3ES_KB3EDG0      
    #endif  
    #ifdef KBI3ES_KBEDG1 
      #define TSS_KBI3P1EDG                   KBI3ES_KBEDG1      
    #elif defined(KBI3ES_KB3EDG1)
      #define TSS_KBI3P1EDG                   KBI3ES_KB3EDG1      
    #endif  
    #ifdef KBI3ES_KBEDG2 
      #define TSS_KBI3P2EDG                   KBI3ES_KBEDG2      
    #elif defined(KBI3ES_KB3EDG2)
      #define TSS_KBI3P2EDG                   KBI3ES_KB3EDG2      
    #endif  
    #ifdef KBI3ES_KBEDG3 
      #define TSS_KBI3P3EDG                   KBI3ES_KBEDG3      
    #elif defined(KBI3ES_KB3EDG3)
      #define TSS_KBI3P3EDG                   KBI3ES_KB3EDG3      
    #endif  
    #ifdef KBI3ES_KBEDG4 
      #define TSS_KBI3P4EDG                   KBI3ES_KBEDG4      
    #elif defined(KBI3ES_KB3EDG4)
      #define TSS_KBI3P4EDG                   KBI3ES_KB3EDG4      
    #endif  
    #ifdef KBI3ES_KBEDG5 
      #define TSS_KBI3P5EDG                   KBI3ES_KBEDG5      
    #elif defined(KBI3ES_KB3EDG5)
      #define TSS_KBI3P5EDG                   KBI3ES_KB3EDG5      
    #endif  
    #ifdef KBI3ES_KBEDG6 
      #define TSS_KBI3P6EDG                   KBI3ES_KBEDG6      
    #elif defined(KBI3ES_KB3EDG6)
      #define TSS_KBI3P6EDG                   KBI3ES_KB3EDG6      
    #endif  
    #ifdef KBI3ES_KBEDG7 
      #define TSS_KBI3P7EDG                   KBI3ES_KBEDG7      
    #elif defined(KBI3ES_KB3EDG7)
      #define TSS_KBI3P7EDG                   KBI3ES_KB3EDG7      
    #endif  
  #else
    #ifdef KBI3SC_KBEDG0
      #define TSS_KBI3P0EDG                   KBI3SC_KBEDG0
    #elif defined(KBI3SC_KB3EDG0)
      #define TSS_KBI3P0EDG                   KBI3SC_KB3EDG0
    #endif
    #ifdef KBI3SC_KBEDG1
      #define TSS_KBI3P1EDG                   KBI3SC_KBEDG1
    #elif defined(KBI3SC_KB3EDG1)
      #define TSS_KBI3P1EDG                   KBI3SC_KB3EDG1
    #endif
    #ifdef KBI3SC_KBEDG2
      #define TSS_KBI3P2EDG                   KBI3SC_KBEDG2
    #elif defined(KBI3SC_KB3EDG2)
      #define TSS_KBI3P2EDG                   KBI3SC_KB3EDG2
    #endif
    #ifdef KBI3SC_KBEDG3
      #define TSS_KBI3P3EDG                   KBI3SC_KBEDG3
    #elif defined(KBI3SC_KB3EDG3)
      #define TSS_KBI3P3EDG                   KBI3SC_KB3EDG3
    #endif
    #ifdef KBI3SC_KBEDG4
      #define TSS_KBI3P4EDG                   KBI3SC_KBEDG4
    #elif defined(KBI3SC_KB3EDG4)
      #define TSS_KBI3P4EDG                   KBI3SC_KB3EDG4
    #endif
    #ifdef KBI3SC_KBEDG5
      #define TSS_KBI3P5EDG                   KBI3SC_KBEDG5
    #elif defined(KBI3SC_KB3EDG5)
      #define TSS_KBI3P5EDG                   KBI3SC_KB3EDG5
    #endif
    #ifdef KBI3SC_KBEDG6
      #define TSS_KBI3P6EDG                   KBI3SC_KBEDG6
    #elif defined(KBI3SC_KB3EDG6)
      #define TSS_KBI3P6EDG                   KBI3SC_KB3EDG6
    #endif
    #ifdef KBI3SC_KBEDG7
      #define TSS_KBI3P7EDG                   KBI3SC_KBEDG7
    #elif defined(KBI3SC_KB3EDG7)
      #define TSS_KBI3P7EDG                   KBI3SC_KB3EDG7
    #endif
  #endif

  /* JR12 exception */
  #define TSS_KBIP8EDG                        TSS_KBI2P0EDG
  #define TSS_KBIP9EDG                        TSS_KBI2P1EDG  
  #define TSS_KBIP10EDG                       TSS_KBI2P2EDG
  #define TSS_KBIP11EDG                       TSS_KBI2P3EDG
  #define TSS_KBIP12EDG                       TSS_KBI2P4EDG
  #define TSS_KBIP13EDG                       TSS_KBI2P5EDG
  #define TSS_KBIP14EDG                       TSS_KBI2P6EDG
  #define TSS_KBIP15EDG                       TSS_KBI2P7EDG

  #define TSS_KBI_TO_EDG(reg)                 TSS_##reg##EDG
  #define TSS_SET_EL_KBI_EDG_CONV(name)       TSS_KBI_TO_EDG(name)
  #define TSS_SET_EL_KBI_EDG(el)              TSS_SET_EL_KBI_EDG_CONV(TSS_E##el##_TYPE)

  #define TSS_KBI_TO_IE(reg)                  reg##SC_KBIE
  #define TSS_KBI_ENABLE_INT(num)             (TSS_KBI_TO_IE(num) = 1u)
  
  #define TSS_KBI_TO_ACK(reg)                 reg##SC_KBACK
  #define TSS_KBI_ACK(num)                    (TSS_KBI_TO_ACK(num) = 1u)
  
  /* Special MCU exceptions solving */

  /* DE60 exception */
  #if TSS_DETECT_MODULE(KBI)
    #ifndef VectorNumber_Vkeyboard 
      #define VectorNumber_Vkeyboard          VectorNumber_Vkeyboard1
    #endif
  #endif
  
  /* QE128 exception */
  #if TSS_DETECT_MODULE(KBI2)
    #ifndef VectorNumber_Vkeyboard2 
      #ifndef VectorNumber_Vkeyboard1 
        #define VectorNumber_Vkeyboard2       VectorNumber_Vkeyboard
      #endif
    #endif
  #endif
  
  /* QE32 exception */
  #if TSS_DETECT_MODULE(KBI1)
    #ifndef VectorNumber_Vkeyboard1 
      #define VectorNumber_Vkeyboard1         VectorNumber_Vkeyboard
    #endif
  #endif
  
#endif /*__TSS_SENSORKBI_H__*/
